﻿
using Ops.Mpc.Collections;
using Ops.Mpc.States;
using Ops.Mpc.Models;

namespace Ops.Mpc.Presenters
{
    public class Resolver
    {
        #region Fields & Properties
        private Presenter presenter = null;

        public Indexer<Model> Models
        {
            get
            {
                return new Indexer<Model>(this,this.presenter.Controller.GetModel);
            }
        }

        public Indexer<StateAction> StateActions
        {
            get
            {
                return new Indexer<StateAction>(this,this.presenter.Controller.GetStateAction);
            }
        }


        #endregion

        #region Constructors
        public Resolver(Presenter presenter)
        {
            this.presenter = presenter;
        }
        #endregion


        #region helper class
        public class Indexer<Type> where Type: class, INamedItem  
        {
            private Resolver _resolver = null;
            private ResolveItemHandler _resolveItemHandler;

            public Indexer(Resolver resolver, ResolveItemHandler resolveItemHanlder)
            {
                _resolver = resolver;
                _resolveItemHandler = resolveItemHanlder;
            }

            public Type this[string itemName]
            {
                get
                {
                    return _resolveItemHandler(itemName) as Type;

                }
            }
        }
        #endregion
    }



}


